﻿@model ProductModel.ProductAttributeMappingModel
@using Nop.Core.Domain.Catalog
@using Nop.Services

<script type="text/javascript">
    $(document).ready(function() {
        $("#@Html.IdFor(model => model.AttributeControlTypeId)").change(toggleAttributeControlType);

        toggleAttributeControlType();
    });

    function toggleAttributeControlType() {
        var selectedAttributeControlTypeId = $("#@Html.IdFor(model => model.AttributeControlTypeId)").val();
        //validation
        if (selectedAttributeControlTypeId == @(((int) AttributeControlType.TextBox).ToString())) {
            $('#pnlValidationMinLength').show();
            $('#pnlValidationMaxLength').show();
            $('#pnlValidationFileMaximumSize').hide();
            $('#pnlValidationFileAllowedExtensions').hide();
            $('#pnlDefaultValue').show();
        } else if (selectedAttributeControlTypeId == @(((int) AttributeControlType.MultilineTextbox).ToString())) {
            $('#pnlValidationMinLength').show();
            $('#pnlValidationMaxLength').show();
            $('#pnlValidationFileMaximumSize').hide();
            $('#pnlValidationFileAllowedExtensions').hide();
            $('#pnlDefaultValue').show();
        } else if (selectedAttributeControlTypeId == @(((int) AttributeControlType.FileUpload).ToString())) {
            $('#pnlValidationMinLength').hide();
            $('#pnlValidationMaxLength').hide();
            $('#pnlValidationFileMaximumSize').show();
            $('#pnlValidationFileAllowedExtensions').show();
            $('#pnlDefaultValue').hide();
        } else {
            $('#pnlValidationMinLength').hide();
            $('#pnlValidationMaxLength').hide();
            $('#pnlValidationFileMaximumSize').hide();
            $('#pnlValidationFileAllowedExtensions').hide();
            $('#pnlDefaultValue').hide();
        }

        //values
        if (selectedAttributeControlTypeId == @(((int) AttributeControlType.DropdownList).ToString()) ||
            selectedAttributeControlTypeId == @(((int) AttributeControlType.RadioList).ToString()) ||
            selectedAttributeControlTypeId == @(((int) AttributeControlType.Checkboxes).ToString()) ||
            selectedAttributeControlTypeId == @(((int) AttributeControlType.ColorSquares).ToString()) ||
            selectedAttributeControlTypeId == @(((int) AttributeControlType.ImageSquares).ToString()) ||
            selectedAttributeControlTypeId == @(((int) AttributeControlType.ReadonlyCheckboxes).ToString())) {
            $('[data-tab-name=tab-values]').show();
        } else {
            $('[data-tab-name=tab-values]').hide();
        }
    }
</script>
<input asp-for="ProductId" type="hidden" />
<div class="panel-group">
    @await Component.InvokeAsync("AdminWidget", new { widgetZone = "admin_product_attribute_mapping_details_info_top", additionalData = Model.Id })
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="form-group">
                <div class="col-md-3">
                    <nop-label asp-for="ProductAttributeId" />
                </div>
                <div class="col-md-9">
                    <nop-select asp-for="ProductAttributeId" asp-items="Model.AvailableProductAttributes" />
                    <span asp-validation-for="ProductAttributeId"></span>
                </div>
            </div>
            @(Html.LocalizedEditor<ProductModel.ProductAttributeMappingModel, ProductModel.ProductAttributeMappingLocalizedModel>("productattribute-localized",
            @<div>
                <div class="form-group">
                    <div class="col-md-3">
                        <nop-label asp-for="@Model.Locales[item].TextPrompt" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="@Model.Locales[item].TextPrompt" />
                        <span asp-validation-for="@Model.Locales[item].TextPrompt"></span>
                    </div>
                </div>
                <input type="hidden" asp-for="@Model.Locales[item].LanguageId" />
            </div>
    ,
            @<div>
                <div class="form-group">
                    <div class="col-md-3">
                        <nop-label asp-for="TextPrompt" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="TextPrompt" />
                        <span asp-validation-for="TextPrompt"></span>
                    </div>
                </div>
            </div>
                  ))
            <div class="form-group">
                <div class="col-md-3">
                    <nop-label asp-for="IsRequired" />
                </div>
                <div class="col-md-9">
                    <nop-editor asp-for="IsRequired" />
                    <span asp-validation-for="IsRequired"></span>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-3">
                    <nop-label asp-for="AttributeControlTypeId" />
                </div>
                <div class="col-md-9">
                    <nop-select asp-for="AttributeControlTypeId" asp-items="@(((AttributeControlType)Model.AttributeControlTypeId).ToSelectList())" />
                    <span asp-validation-for="AttributeControlTypeId"></span>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-3">
                    <nop-label asp-for="DisplayOrder" />
                </div>
                <div class="col-md-9">
                    <nop-editor asp-for="DisplayOrder" />
                    <span asp-validation-for="DisplayOrder"></span>
                </div>
            </div>
            <div class="form-group" id="pnlValidationMinLength">
                <div class="col-md-3">
                    <nop-label asp-for="ValidationMinLength" />
                </div>
                <div class="col-md-9">
                    <nop-editor asp-for="ValidationMinLength" />
                    <span asp-validation-for="ValidationMinLength"></span>
                </div>
            </div>
            <div class="form-group" id="pnlValidationMaxLength">
                <div class="col-md-3">
                    <nop-label asp-for="ValidationMaxLength" />
                </div>
                <div class="col-md-9">
                    <nop-editor asp-for="ValidationMaxLength" />
                    <span asp-validation-for="ValidationMaxLength"></span>
                </div>
            </div>
            <div class="form-group" id="pnlValidationFileAllowedExtensions">
                <div class="col-md-3">
                    <nop-label asp-for="ValidationFileAllowedExtensions" />
                </div>
                <div class="col-md-9">
                    <nop-editor asp-for="ValidationFileAllowedExtensions" />
                    <span asp-validation-for="ValidationFileAllowedExtensions"></span>
                </div>
            </div>
            <div class="form-group" id="pnlValidationFileMaximumSize">
                <div class="col-md-3">
                    <nop-label asp-for="ValidationFileMaximumSize" />
                </div>
                <div class="col-md-9">
                    <nop-editor asp-for="ValidationFileMaximumSize" />
                    <span asp-validation-for="ValidationFileMaximumSize"></span>
                </div>
            </div>
            <div class="form-group" id="pnlDefaultValue">
                <div class="col-md-3">
                    <nop-label asp-for="DefaultValue" />
                </div>
                <div class="col-md-9">
                    <nop-editor asp-for="DefaultValue" />
                    <span asp-validation-for="DefaultValue"></span>
                </div>
            </div>
        </div>
    </div>
    @await Component.InvokeAsync("AdminWidget", new { widgetZone = "admin_product_attribute_mapping_details_info_bottom", additionalData = Model.Id })
</div>